<template>
    <div class="goods">
        <goods-list-item v-for="(item,index) in goods.list" :product="item" :key="index" @click="goDetail(item.id)"></goods-list-item>
    </div>
</template>
<script>
import {reactive,toRefs} from "vue";
import GoodsListItem from "./GoodsListItem";
import {useRouter} from "vue-router";

export default {
    components: {GoodsListItem},
    props:{
        goods: {
            type: Array,
            default(){
                return []
            }
        }
    },
    setup(){
        const route = new useRouter()
        const state = reactive({
            count:0
        })
        const goDetail = (id) => {
          route.push({
              path:'/detail',
              query:{id}
          })
        }
        return{
            ...toRefs(state),
            goDetail
        }
    }
}

</script>

<style scoped>
.goods{
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    padding: 5px;
}
</style>
